package com.shaoshaohuo.app.adapter;

import java.util.List;

import com.shaoshaohuo.app.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class StringGridviewAdapter<T> extends MyBaseAdapter<String> {

	private int selectPosition = -1;

    public StringGridviewAdapter(Context ctx, List<String> list, boolean flag) {
		super(ctx, list, flag);
	}

	@Override
	public View getView(int pos, View convertView, ViewGroup group) {
		
		ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(context,R.layout.view_added_service_item, null);
            holder = new ViewHolder();
            holder.titleText = (TextView) convertView.findViewById(R.id.textview_text);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
		
        String item = list.get(pos);
        
        
        if(selectPosition == pos){
            convertView.setActivated(true);
        }else{
            convertView.setActivated(false);
        }
        
        holder.titleText.setText(item);
        
		return convertView;
	}
	
	static class ViewHolder{
		TextView titleText;
	}
	
	public void setSelectPosition(int pos){
	    this.selectPosition = pos;
	    notifyDataSetChanged();
	}
	
}
